<style type='text/css'>
    .diyform-container .short {border:1px solid red;}
</style>
<div class='fui-cell-group diyform-container'>
    {php $i=0;}
    {loop $fields $k1 $v1}
    <div class='fui-cell {if $v1['tp_must'] == 1}must{/if}'
    data-must="{$v1['tp_must']}"
    data-type="{$v1['data_type']}"
    data-name="{$v1['tp_name']}"
    data-name2="{$v1['tp_name2']}"
    data-isdefault="{$v1['tp_is_default']}"
    data-itemid="field_data{php echo $i}"
    data-key="{$k1}"
    >
    <div class='fui-cell-label' style="width: auto;padding-right: 15px;">
        {php echo $v1['tp_name']}
        {if $v1['data_type'] == 10}
        <br>
        {php echo $v1['tp_name2']}
        {/if}
    </div>

    <div class='fui-cell-info'>

        {if $v1['data_type'] == 0}

        <input type="text" class='fui-input' id='field_data{php echo $i}' name='field_data{php echo $i}' placeholder="{if !empty($v1['placeholder'])}{$v1['placeholder']}{else}请输入{$v1['tp_name']}{/if}"  value="{php echo $f_data[$k1]}" />
        {else if $v1['data_type'] == 1}
        <textarea class="" id='field_data{php echo $i}' name='field_data{php echo $i}' placeholder="{if !empty($v1['placeholder'])}{$v1['placeholder']}{else}请输入{$v1['tp_name']}{/if}" >{php echo $f_data[$k1]}</textarea>

        {else if $v1['data_type'] == 2}
        <select id='field_data{php echo $i}' name='field_data{php echo $i}' >
            <option value=''>请选择{$v1['tp_name']}</option>
            {loop $v1['tp_text'] $k2 $v2}
            <option value="{php echo $v2}" {if $f_data[$k1] == $v2}selected{/if}>{php echo $v2}</option>
            {/loop}
        </select>

        {else if $v1['data_type'] == 3}
        {loop $v1['tp_text'] $k2 $v2}
        <label class="checkbox-inline">
            <input type="checkbox" class='fui-checkbox fui-checkbox-success' name='field_data{php echo $i}[]' {if is_array($f_data[$k1]) &&  in_array($v2, $f_data[$k1])}checked{/if} value="{php echo $v2}"/> {php echo $v2}
        </label>
        {/loop}

        {else if $v1['data_type'] == 5}
        {php $img_max=$v1['tp_max'];}


        <ul class="fui-images fui-images-sm" id="field_data{php echo $i}_images">
            {if !empty($f_data[$k1])}
            {loop $f_data[$k1] $k2 $v2}
            <input type="hidden" name="field_data{php echo $i}[]" value="{$v2}" />
            <li style="background-image:url({php echo tomedia($v2)})" class="image image-sm" data-filename="{$v2}"><span class="image-remove"><i class="icon icon-roundclose"></i></span></li>
            {/loop}
            {/if}

        </ul>
        <div class="fui-uploader fui-uploader-sm diyform-container-uploader" {if !empty($f_data[$k1])}{if $img_max == count($f_data[$k1])}style='display:none'{/if}{/if}
        data-name="field_data{php echo $i}[]"
        data-max="{$img_max}"
        data-count="{if !empty($f_data[$k1])}{php echo count($f_data[$k1])}{else}0{/if}">
        <input type="file"name='imgFile{php echo $i}' id='imgFile{php echo $i}' {if !is_h5app() || (is_h5app() && is_ios())}multiple="" accept="image/*" {/if} >
    </div>




    {else if $v1['data_type'] == 6}
    <input type="text" class='fui-input' id='field_data{php echo $i}' name='field_data{php echo $i}' placeholder="请输入{$v1['tp_name']}" maxlength="18" value="{php echo $f_data[$k1]}" />

    {else if $v1['data_type'] == 7}
    <input type="text" class='fui-input datepicker' id="field_data{php echo $i}" name='field_data{php echo $i}' placeholder="请输入{$v1['tp_name']}"  readonly value='{if !empty($f_data[$k1])}{php echo $f_data[$k1]}{/if}'/>

    {else if $v1['data_type'] == 8}

    <input type="text" class='fui-input datepicker'  id="field_data{php echo $i}_0" name='field_data{php echo $i}' placeholder="开始日期" readonly value='{if !empty($f_data[$k1][0])}{php echo $f_data[$k1][0]}{/if}' style='width:40%;float:left;' readonly/>

    <input type="text" class='fui-input datepicker'  id="field_data{php echo $i}_1" name='field_data{php echo $i}' placeholder="结束日期" readonly value='{if !empty($f_data[$k1][1])}{php echo $f_data[$k1][1]}{/if}' style='width:40%;float:left;margin-left:5px;' readonly/>

    {else if $v1['data_type'] == 9}
    <input type="text" class='fui-input citypicker' id="field_data{php echo $i}" name='field_data{php echo $i}' placeholder="请选择{$v1['tp_name']}"  readonly value="{php echo !empty($f_data[$k1]['province']) && !empty($f_data[$k1]['city']) ?($f_data[$k1]['province'].' '.$f_data[$k1]['city']):''}"/>

    {else if $v1['data_type'] == 10}
    <input type="text" class='fui-input' id='field_data{php echo $i}' name='field_data{php echo $i}' placeholder="请输入{$v1['tp_name']}"  value="{php echo $f_data[$k1]['name1']}" />
    <br/>
    <input type="text" class='fui-input' id='field_data{php echo $i}_2' name='field_data{php echo $i}_2' placeholder="请输入{$v1['tp_name2']}"  value="{php echo $f_data[$k1]['name2']}" />
    {/if}


</div>
</div>


{php $i++;}
{/loop}
<script language='javascript'>
    require(['foxui','foxui.picker'],function(){
        $('.diyform-container .datepicker').datePicker({
            onShow:function(){
                {if $inPicker}
                    $('.option-picker').css('z-index',999);
                    $('.fui-mask').unbind('click').click(function(){
                        $('.diyform-container .datepicker').datePicker('close');
                    });
                    {/if}
                    }
                ,onClose:function(){
                    {if $inPicker}
                        $('.option-picker').css('z-index',1001);
                        $('.fui-mask').unbind('click').click(function(){
                            FoxUI.mask.hide();
                            $('.option-picker').removeClass('in');
                        });
                        {/if}
                        }
                    });
                    $('.diyform-container .citypicker').cityPicker({
                        showArea:false,
                        onShow:function(){

                            {if $inPicker}
                                $('.option-picker').css('z-index',999);
                                $('.fui-mask').unbind('click').click(function(){
                                    $('.diyform-container .datepicker').cityPicker('close');
                                });
                                {/if}
                                }
                            ,onClose:function(){
                                {if $inPicker}
                                    $('.option-picker').css('z-index',1001);
                                    $('.fui-mask').unbind('click').click(function(){
                                        FoxUI.mask.hide();
                                        $('.option-picker').removeClass('in');
                                    });
                                    {/if}
                                    }
                                });
                                $('.diyform-container .diyform-container-uploader').uploader({
                                    uploadUrl: "{php echo mobileUrl('util/uploader')}",
                                    removeUrl:"{php echo mobileUrl('util/uploader/remove')}"
                                });
                            })
</script>
</div>
